xref: /haiku/src/kits/package/Request.cpp (revision 35edda8f0befb8667b593e2314f6d555a7db44d8)
1 /*
2  * Copyright 2011, Haiku, Inc. All Rights Reserved.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Oliver Tappe <zooey@hirschkaefer.de>
7  */
8 
9 
10 #include <package/Request.h>
11 
12 #include <package/Context.h>
13 #include <package/Job.h>
14 
15 
16 namespace Haiku {
17 
18 namespace Package {
19 
20 
21 Request::Request(const Context& context)
22 	:
23 	fContext(context),
24 	fJobQueue()
25 {
26 }
27 
28 
29 Request::~Request()
30 {
31 }
32 
33 
34 Job*
35 Request::PopRunnableJob()
36 {
37 	return fJobQueue.Pop();
38 }
39 
40 
41 status_t
42 Request::QueueJob(Job* job)
43 {
44 	job->AddStateListener(this);
45 
46 	JobStateListener* listener = fContext.GetJobStateListener();
47 	if (listener != NULL)
48 		job->AddStateListener(listener);
49 
50 	return fJobQueue.AddJob(job);
51 }
52 
53 
54 }	// namespace Package
55 
56 }	// namespace Haiku
57